#include <iostream>      
#include <vector>      
#include <string>      
#include <set>   
#include <map>   

#define X       first      
#define Y       second      

using namespace std;      

typedef pair<int, int>  Point;      

map<char, Point> move;   

void process()      
{      
	string in;      
	cin >> in;      

	int n = in.size() / 2;      

	vector<Point>   chain;      
	set<Point>      visited;   

	Point cur(0, 0);      
	chain.push_back(cur);   
	visited.insert(cur);   

	for(int i = 0; i < n; i++)
	{      
		int m = in[i*2+1] - '0';   
		if(m == 0) continue;   

		for(int j = 0; j < m; j++)   
		{   
			cur.X += move[in[i*2]].X;   
			cur.Y += move[in[i*2]].Y;   

			if(visited.find(cur) != visited.end())   
			{   
				for(Point pt = chain.back(); pt != cur; pt = chain.back())   
				{   
					visited.erase(pt);   
					chain.pop_back();   
				}   
			}   
			else  
			{   
				chain.push_back(cur);   
				visited.insert(cur);   
			}   
		}   
	}      

	int cnt = 0;   
	for(int i = 1; i < chain.size(); i++)      
	{   
		if(i == 1) cnt++;   
		else if((chain[i-2].X == chain[i-1].X && chain[i-1].X != chain[i].X) ||   
				(chain[i-2].Y == chain[i-1].Y && chain[i-1].Y != chain[i].Y) )   
			cnt++;   
	}   

	cout << cnt << " " << chain.size()-1 << endl;      
}      

int main()      
{   
#define SUBMIT 0
#if !SUBMIT
	freopen("DATA.in", "rt", stdin);
	freopen("DATA.ou", "wt", stdout);
#endif
	move['E'] = Point( 1,  0);   
	move['W'] = Point(-1,  0);   
	move['N'] = Point( 0,  1);   
	move['S'] = Point( 0, -1);   

	int t;      
	cin >> t;      
	while(t--) process();      
}      





